import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SerializerTest {
    @Before
    public void setUp() throws Exception {

    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void testSerialize_int() throws Exception {
        int a = 566;
        assert(Deserializer.deserialize_int(Serializer.serialize_int(a)) == a);

        a = Integer.MIN_VALUE;
        assert(Deserializer.deserialize_int(Serializer.serialize_int(a)) == a);

        a = Integer.MAX_VALUE;
        assert(Deserializer.deserialize_int(Serializer.serialize_int(a)) == a);

        a = 0;
        assert(Deserializer.deserialize_int(Serializer.serialize_int(a)) == a);
    }

    @Test
    public void testSerialize_long() throws Exception {
        long a = 566L;
        assert(Deserializer.deserialize_long(Serializer.serialize_long(a)) == a);

        a = (1L << 34) - 3;
        assert(Deserializer.deserialize_long(Serializer.serialize_long(a)) == a);

        a = Long.MIN_VALUE;
        assert(Deserializer.deserialize_long(Serializer.serialize_long(a)) == a);

        a = Long.MAX_VALUE;
        assert(Deserializer.deserialize_long(Serializer.serialize_long(a)) == a);

        a = 0;
        assert(Deserializer.deserialize_long(Serializer.serialize_long(a)) == a);
    }

    @Test
    public void testSerialize_double() throws Exception {
        double a = 0.12323e-12;
        assert(Deserializer.deserialize_double(Serializer.serialize_double(a)) == a);

        a = Double.MIN_VALUE;
        assert(Deserializer.deserialize_double(Serializer.serialize_double(a)) == a);

        a = Double.MAX_VALUE;
        assert(Deserializer.deserialize_double(Serializer.serialize_double(a)) == a);

        a = 0;
        assert(Deserializer.deserialize_double(Serializer.serialize_double(a)) == a);
    }

    @Test
    public void testSerialize_string() throws Exception {
        String s = "abcd";
        assert(Deserializer.deserialize_string(Serializer.serialize_string(s)).equals(s));

        s = "zdrthnqklfuioqpvm";
        while (s.length() < 500) s += s;
        assert(Deserializer.deserialize_string(Serializer.serialize_string(s)).equals(s));

        s = "";
        assert(Deserializer.deserialize_string(Serializer.serialize_string(s)).equals(s));

        s = "akjfhaieufgaengignsldngkjdanajgnvajbnajnglafngdanjanlganjhlxhnsdgfndajgxndfaagndhgfdngikandxgmergixea" +
                "rngxtjthjeqpzjtguttjqtjxgsadpigjbfdmagbgbemigxjeirgijnwgwjgjxpodskgsrhcjsbj";
        assert(Deserializer.deserialize_string(Serializer.serialize_string(s)).equals(s));
    }
}